

#include <cstdlib>
#include <iomanip>
#include <iostream>
//#include "../GeoMath2.0/GeoMathInc/TGS/GeoMath2.0/Line.h"
//#include "../GeoMath2.0/GeoMathInc/TGS/GeoMath2.0/CGAlgorithms.h"

#include "../GeoMathInc/TGS/GeoMath2.0/GeoMath2.0.h"

using namespace TGS::GeoMath;



int main(int argc, const char* argv[])
{
	using namespace TGS::GeoMath;

	Envelope e1(0, 0, 5, 5);
	Envelope e2(-2, -2, 4, 4);
	Envelope r;
	e1.intersect(e2, r);
	
	double xxxxxxxx = Angle::fromD_MS(116.62000000).toD_MS();

	Point pp(129450.75767606027, 334811.22260316601);
	Line lt(Angle::fromRadian(2.4776997399485503), pp);
	double xx = CGAlgorithms::distance(pp, lt);

	Line h(Point(1, 0), Point(0, 0));
	Line v(Point(0, 1), Point(0, 0));

	bool b = h.isHorizontal();
	b = h.isVertical();
	b = v.isHorizontal();
	b = v.isVertical();
	b = v.isParallel(h);
	b = v.isPerpendicular(h);


	Line line(Point(2, 0), Point(0, 2));
	Line line1(Point(1, 1), Point(0, 0));
	auto kk = line.interset(line1);
	double d = CGAlgorithms::distance(Point(0, 0), line);

	b = line.isPerpendicular(line1);

	Polygon p1;
	p1.appendPoint(0, 0);
	p1.appendPoint(4, 0);
	p1.appendPoint(4, 4);
	p1.appendPoint(0, 4);


	MultiPolygon p = p1.buffer(1);

	Polygon p2;
	p2.appendPoint(0, 0);
	p2.appendPoint(8, 0);
	p2.appendPoint(8, 8);
	p2.appendPoint(0, 8);
	p2.appendPoint(0, 0);

	Point center = p2.getInteriorPoint();

	MultiPolygon mp = PolygonClipper::intersect(p2, p1);
	mp = PolygonClipper::unionPolygons(p1, p2);
	mp = PolygonClipper::difference(p2, p1);
	mp = PolygonClipper::XOR(p1, p2);

	SpaceIndexManager spaceIndex(Point(0, 0), 1);
	auto k1 = spaceIndex.calculatePointSpaceIndex(Point(.5, 3.7));
	auto k2 = spaceIndex.getRowColumnIndex(k1);
	auto k3 = spaceIndex.calculateCellPolygon(k1);
	auto k4 = spaceIndex.getSpaceInfo(k1);
	auto k5 = spaceIndex.calculatePolygonSpaceIndices(p1);

	for (int i = 0; i < k5.size(); ++i)
	{
		k2 = spaceIndex.getRowColumnIndex(k5[i]);

		int kkk = 0;
	}

	int c = 0;
}
